﻿using Microsoft.Practices.Composite.Events;
using SL4_MVVM_MEF.MEFModule;
using SL4_MVVM_MEF.MEFModule.Model;
using SL4_MVVM_MEF.MEFModule.Services;

namespace SL4_MVVM_MEF_UnitTests.Mocks
{
    /// <summary>
    /// Service used for tests only
    /// </summary>
    public class MockDataItemsService : IDataItemsService
    {
        private readonly IEventAggregator _eventAggregator;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="eventAggregator">EventAggregator instance imported via MEF</param>
        public MockDataItemsService(IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
        }

        public void GetDataItems()
        {
            var dataItems = new DataItems
                                {
                                    new DataItem() {Description = "Sample Data Item 1 - Test Mode"},
                                    new DataItem() {Description = "Sample Data Item 2 - Test Mode"},
                                    new DataItem() {Description = "Sample Data Item 3 - Test Mode"},
                                    new DataItem() {Description = "Sample Data Item 4 - Test Mode"}
                                };

            //Publish the DataItems
            _eventAggregator.GetEvent<DataItemsReceivedEvent>().Publish(dataItems);
        }
    }
}
